﻿using System;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace SedionFormDesigner.CusControls
{
    public class BD_Horizon : UserControl
    {
        private Color lineColor = Color.Black;
        private Int32 lineHeight = 1;
        private Int32 width;
        private static Int32 ctrlCount = 1;

        public BD_Horizon()
        {
            this.width = base.Width;
            this.Height = 2;
            this.Name = ctrlCount.ToString();
            ctrlCount++;
        }

        [Browsable(true)]
        public new Int32 Width
        {
            get { return this.width; }
            set
            {
                this.width = value;
            }
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.DrawLine(new Pen(lineColor), 1, 1, this.Width, lineHeight);
        }

        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            this.Height = 2;
            this.Width = base.Width;
        }

        #region 属性:外观

        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }

        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }

        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
            else
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize);
        }

        #endregion
    }
}
